package com.xcc.singletonpattern;

/**
 * @Description: Singleton
 * @Author xiechuang
 * @Date 2022/9/6
 */
public class Singleton2 {

    private static Singleton2 uniqueInstance;

    private Singleton2() {}

    // version2："延迟实例话"，使用同步，会导致程序性能下降
    public static synchronized Singleton2 getInstance2() {
        if (uniqueInstance == null) {
            uniqueInstance = new Singleton2();
        }
        return uniqueInstance;
    }

}
